home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / obrn-a_1.5_lib.lha / oberon-a / source2.lha / source / amiga / LowLevel.mod < prev    next >
Encoding:
Text File  |  1995-01-26  |  9.3 KB  |  358 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: LowLevel.mod $
  4.   Description: Interface to lowlevel.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.6 $
  8.       $Author: fjc $
  9.         $Date: 1995/01/26 02:39:55 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. *************************************************************************)
  21.  
  22. <* STANDARD- *> <* INITIALISE- *> <* MAIN- *>
  23. <*$ CaseChk-  IndexChk- LongVars+ NilChk-  *>
  24. <*$ RangeChk- StackChk- TypeChk-  OvflChk- *>
  25.  
  26. MODULE [2] LowLevel;
  27.  
  28. IMPORT
  29.   SYS := SYSTEM, Kernel, e := Exec, u := Utility, t := Timer, s := Sets;
  30.  
  31. (*
  32. **      $VER: lowlevel.h 40.6 (30.7.93)
  33. **
  34. **      lowlevel.library interface structures and definitions.
  35. *)
  36.  
  37. (*****************************************************************************)
  38.  
  39. TYPE
  40.  
  41. (* structure for use with QueryKeys() *)
  42.   KeyQueryPtr * = POINTER TO KeyQuery;
  43.   KeyQuery * = RECORD
  44.     keyCode * : e.UWORD;
  45.     pressed * : e.BOOL;
  46.   END;
  47.  
  48.  
  49. (*****************************************************************************)
  50.  
  51. CONST
  52.  
  53. (* bits in the return value of GetKey() *)
  54.   lShift * = 16;
  55.   rShift * = 17;
  56.   capsLock * = 18;
  57.   control * = 19;
  58.   lAlt * = 20;
  59.   rAlt * = 21;
  60.   lAmiga * = 22;
  61.   rAmiga * = 23;
  62.  
  63.  
  64. (*****************************************************************************)
  65.  
  66. CONST
  67.  
  68. (* Tags for SetJoyPortAttrs() *)
  69.   sjaDummy * = u.user + 0C00100H;
  70.   sjaType * = sjaDummy+1;             (* force type to mouse, joy, game cntrlr *)
  71.   sjaReinitialize * = sjaDummy+2;     (* free potgo bits, reset to autosense   *)
  72.  
  73. (* Controller types for sjaType tag *)
  74.   sjaTypeAutoSense * = 0;
  75.   sjaTypeGameCtlr * = 1;
  76.   sjaTypeMouse * = 2;
  77.   sjaTypeJoystk * = 3;
  78.  
  79.  
  80. (*****************************************************************************)
  81.  
  82. CONST
  83.  
  84. (* ReadJoyPort() return value definitions *)
  85.  
  86. (* Port types *)
  87.   typeNotAvail * = 0;               (* port data unavailable    *)
  88.   typeGameCtlr * = 010000000H;      (* port has game controller *)
  89.   typeMouse    * = 020000000H;      (* port has mouse           *)
  90.   typeJoyStk   * = 030000000H;      (* port has joystick        *)
  91.   typeUnknown  * = 040000000H;      (* port has unknown device  *)
  92.   typeMask     * = 0F0000000H;      (* controller type          *)
  93.  
  94. (* Button types, valid for all types except JP_TYPE_NOTAVAIL *)
  95.   buttonBlue    * = 23;        (* Blue - Stop; Right Mouse                *)
  96.   buttonRed     * = 22;        (* Red - Select; Left Mouse; Joystick Fire *)
  97.   buttonYellow  * = 21;        (* Yellow - Repeat                         *)
  98.   buttonGreen   * = 20;        (* Green - Shuffle                         *)
  99.   buttonForward * = 19;        (* Charcoal - Forward              *)
  100.   buttonReverse * = 18;        (* Charcoal - Reverse              *)
  101.   buttonPlay    * = 17;        (* Grey - Play/Pause; Middle Mouse         *)
  102.   buttonMask    * = { buttonBlue, buttonRed, buttonYellow,
  103.                      buttonGreen, buttonForward, buttonReverse,
  104.                      buttonPlay };
  105.  
  106. (* Direction types, valid for jpTypeGamectlr and jpTypeJoystk *)
  107.   joyUp    * = 3;
  108.   joyDown  * = 2;
  109.   joyLeft  * = 1;
  110.   joyRight * = 0;
  111.   directionMask * = {joyUp, joyDown, joyLeft, joyRight};
  112.  
  113. (* Mouse position reports, valid for jpTypeMouse *)
  114.   mHorzMask * = 0FFH;                  (* horzizontal position *)
  115.   mVertMask * = 0FF00H;                (* vertical position    *)
  116.   mouseMask * = mHorzMask + mVertMask;
  117.  
  118. (* Obsolete ReadJoyPort() definitions, here for source code compatibility only.
  119.  * Please do NOT use in new code.
  120.  *)
  121.   btn1 *  = buttonBlue;
  122.   btn2 *  = buttonRed;
  123.   btn3 *  = buttonYellow;
  124.   btn4 *  = buttonGreen;
  125.   btn5 *  = buttonForward;
  126.   btn6 *  = buttonReverse;
  127.   btn7 *  = buttonPlay;
  128.   up *    = joyUp;
  129.   down *  = joyDown;
  130.   left *  = joyLeft;
  131.   right * = joyRight;
  132.  
  133.  
  134. (*****************************************************************************)
  135.  
  136. CONST
  137.  
  138. (* Tags for SystemControl() *)
  139.   sconDummy *         = u.user + 000C00000H;
  140.   sconTakeOverSys *   = sconDummy+0;
  141.   sconKillReq *       = sconDummy+1;
  142.   sconCDReboot *      = sconDummy+2;
  143.   sconStopInput *     = sconDummy+3;
  144.   sconAddCreateKeys * = sconDummy+4;
  145.   sconRemCreateKeys * = sconDummy+5;
  146.  
  147. (* Reboot control values for use with SCON_CDReboot tag *)
  148.   cdRebootOn *      = 1;
  149.   cdRebootOff *     = 0;
  150.   cdRebootDefault * = 2;
  151.  
  152.  
  153. (*****************************************************************************)
  154.  
  155. CONST
  156.  
  157. (* Rawkey codes returned when using sconAddCreateKeys with SystemControl() *)
  158.  
  159.   port0ButtonBlue * = 072H;
  160.   port0ButtonRed * = 078H;
  161.   port0ButtonYellow * = 077H;
  162.   port0ButtonGreen * = 076H;
  163.   port0ButtonForward * = 075H;
  164.   port0ButtonReverse * = 074H;
  165.   port0ButtonPlay * = 073H;
  166.   port0JoyUp * = 079H;
  167.   port0JoyDown * = 07AH;
  168.   port0JoyLeft * = 07CH;
  169.   port0JoyRight * = 07BH;
  170.  
  171.   port1ButtonBlue * = 0172H;
  172.   port1ButtonRed * = 0178H;
  173.   port1ButtonYellow * = 0177H;
  174.   port1ButtonGreen * = 0176H;
  175.   port1ButtonForward * = 0175H;
  176.   port1ButtonReverse * = 0174H;
  177.   port1ButtonPlay * = 0173H;
  178.   port1JoyUp * = 0179H;
  179.   port1JoyDown * = 017AH;
  180.   port1JoyLeft * = 017CH;
  181.   port1JoyRight * = 017BH;
  182.  
  183.   port2ButtonBlue * = 0272H;
  184.   port2ButtonRed * = 0278H;
  185.   port2ButtonYellow * = 0277H;
  186.   port2ButtonGreen * = 0276H;
  187.   port2ButtonForward * = 0275H;
  188.   port2ButtonReverse * = 0274H;
  189.   port2ButtonPlay * = 0273H;
  190.   port2JoyUp * = 0279H;
  191.   port2JoyDown * = 027AH;
  192.   port2JoyLeft * = 027CH;
  193.   port2JoyRight * = 027BH;
  194.  
  195.   port3ButtonBlue * = 0372H;
  196.   port3ButtonRed * = 0378H;
  197.   port3ButtonYellow * = 0377H;
  198.   port3ButtonGreen * = 0376H;
  199.   port3ButtonForward * = 0375H;
  200.   port3ButtonReverse * = 0374H;
  201.   port3ButtonPlay * = 0373H;
  202.   port3JoyUp * = 0379H;
  203.   port3JoyDown * = 037AH;
  204.   port3JoyLeft * = 037CH;
  205.   port3JoyRight * = 037BH;
  206.  
  207.  
  208. (*****************************************************************************)
  209.  
  210. CONST
  211.  
  212. (* Return values for GetLanguageSelection() *)
  213.   langUnknown * = 0;
  214.   american * = 1;           (* American English *)
  215.   english * = 2;            (* British English  *)
  216.   german * = 3;
  217.   french * = 4;
  218.   spanish * = 5;
  219.   italian * = 6;
  220.   portuguese * = 7;
  221.   danish * = 8;
  222.   dutch * = 9;
  223.   norwegian * = 10;
  224.   finnish * = 11;
  225.   swedish * = 12;
  226.   japanese * = 13;
  227.   chinese * = 14;
  228.   arabic * = 15;
  229.   greek * = 16;
  230.   hebrew * = 17;
  231.   korean * = 18;
  232.  
  233.  
  234. (*****************************************************************************)
  235.  
  236. (*-- Library Base variable --------------------------------------------*)
  237.  
  238. CONST
  239.  
  240.   lowlevelName * = "lowlevel.library";
  241.  
  242. VAR
  243.  
  244.   base* : e.LibraryPtr;
  245.  
  246.  
  247. (*-- Library Functions ------------------------------------------------*)
  248.  
  249. TYPE
  250.   (* some dummys for type security *)
  251.   KBIntHandle     * = POINTER TO RECORD END;
  252.   TimerIntHandle  * = POINTER TO RECORD END;
  253.   VBlankIntHandle * = POINTER TO RECORD END;
  254.  
  255.   (* easy handling of GetKey() result *)
  256.   KeyDescription * = RECORD
  257.     qualifier *: s.SET16;
  258.     code      *: INTEGER;
  259.   END;
  260.  
  261. (*
  262. **      $VER: lowlevel_protos.h 40.6 (30.7.93)
  263. *)
  264.  
  265. (*--- functions in V40 or higher (Release 3.1) ---*)
  266.  
  267. (* CONTROLLER HANDLING *)
  268.  
  269. PROCEDURE ReadJoyPort* [base,-30]
  270.   ( port [0] : e.ULONG )
  271.   : s.SET32;
  272.  
  273. (* LANGUAGE HANDLING *)
  274.  
  275. PROCEDURE GetLanguageSelection* [base,-36] ()
  276.   : SHORTINT;
  277.  
  278. (* KEYBOARD HANDLING *)
  279.  
  280. PROCEDURE GetKey* [base,-48] ()
  281.   : e.ULONG;
  282. PROCEDURE QueryKeys* [base,-54]
  283.   ( queryArray [8] : KeyQueryPtr;
  284.     arraySize  [1] : e.ULONG );
  285. PROCEDURE AddKBInt* [base,-60]
  286.   ( intRoutine [8] : e.PROC;
  287.     intData    [9] : e.APTR )
  288.   : KBIntHandle;
  289. PROCEDURE RemKBInt* [base,-66]
  290.   ( intHandle [9] : KBIntHandle );
  291.  
  292. (* SYSTEM HANDLING *)
  293.  
  294. PROCEDURE SystemControlA* [base,-72]
  295.   ( tagList [9] : ARRAY OF u.TagItem )
  296.   : u.TagID;
  297. PROCEDURE SystemControl* [base,-72]
  298.   ( tagList [9]..: u.Tag )
  299.   : u.TagID;
  300.  
  301. (* TIMER HANDLING *)
  302.  
  303. PROCEDURE AddTimerInt* [base,-78]
  304.   ( intRoutine [8] : e.PROC;
  305.     intData    [9] : e.APTR )
  306.   : TimerIntHandle;
  307. PROCEDURE RemTimerInt* [base,-84]
  308.   ( intHandle [9] : TimerIntHandle );
  309. PROCEDURE StopTimerInt* [base,-90]
  310.   ( intHandle [9] : TimerIntHandle );
  311. PROCEDURE StartTimerInt* [base,-96]
  312.   ( intHandle    [9] : TimerIntHandle;
  313.     timeInterval [0] : e.ULONG;
  314.     continuous   [1] : e.LONGBOOL );
  315. PROCEDURE ElapsedTime* [base,-102]
  316.   ( VAR context [8] : t.EClockVal )
  317.   : e.ULONG;
  318.  
  319. (* VBLANK HANDLING *)
  320.  
  321. PROCEDURE AddVBlankInt* [base,-108]
  322.   ( intRoutine [8] : e.PROC;
  323.     intData    [9] : e.APTR )
  324.   : VBlankIntHandle;
  325. PROCEDURE RemVBlankInt* [base,-114]
  326.   ( intHandle [9] : VBlankIntHandle );
  327.  
  328. (* MORE CONTROLLER HANDLING *)
  329.  
  330. PROCEDURE SetJoyPortAttrsA* [base,-132]
  331.   ( portNumber [0] : e.ULONG;
  332.     tagList    [9] : ARRAY OF u.TagItem )
  333.   : BOOLEAN;
  334. PROCEDURE SetJoyPortAttrs* [base,-132]
  335.   ( portNumber [0]  : e.ULONG;
  336.     tagList    [9]..: u.Tag )
  337.   : BOOLEAN;
  338.  
  339. (* only a dummy to make sure SIZE(KeyDescriptor) = SIZE(LONGINT) *)
  340. PROCEDURE [0] CheckKeyDescriptorSize(kd: KeyDescription): LONGINT;
  341. BEGIN
  342.   RETURN SYS.VAL(LONGINT,kd);
  343. END CheckKeyDescriptorSize;
  344.  
  345. (*-- Library Base variable --------------------------------------------*)
  346.  
  347. (*-----------------------------------*)
  348. PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
  349.  
  350. BEGIN (* CloseLib *)
  351.   IF base # NIL THEN e.CloseLibrary (base) END
  352. END CloseLib;
  353.  
  354. BEGIN
  355.   base := e.OpenLibrary (lowlevelName, e.libraryMinimum);
  356.   IF base # NIL THEN Kernel.SetCleanup (CloseLib) END
  357. END LowLevel.
  358.